package com.medsys.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Classe representa um m�dico do hospital
 * @author Felipe Lauksas
 *
 */
@Entity
@Table(name="medicos")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Medico extends Funcionario implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2149238347666011859L;

	public Medico() {
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * Construtor com os paremetros da classe
	 * @param crm
	 */
	public Medico(String crm) {
		super();
		this.crm = crm;
	}
/*	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;*/
	@Column(name="crm")
	private String crm;
	
	@OneToMany(mappedBy="medico")
	private List<Consulta> listConsultas = new ArrayList<Consulta>();

	/**
	 * @return o crm
	 */
	public String getCrm() {
		return crm;
	}

	/**
	 * @param crm configura o CRM do m�dico
	 */
	public void setCrm(String crm) {
		this.crm = crm;
	}
	
	/**
	 * 
	 * @return {@link List} com todas as {@link Consulta} do {@link Medico}.
	 */
	public List<Consulta> getListConsultas() {
		return listConsultas;
	}
	/**
	 * Configura as {@link Consulta} do {@link Medico} atrav�s de uma {@link List} com objetos {@link Consulta}.
	 * @param listConsultas do tipo {@link List}.
	 */
	public void setListConsultas(List<Consulta> listConsultas) {
		this.listConsultas = listConsultas;
	}


	/**
	 * @return the id
	 */
/*	public Long getId() {
		return id;
	}

	*//**
	 * @param id the id to set
	 *//*
	public void setId(Long id) {
		this.id = id;
	}*/

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((crm == null) ? 0 : crm.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Medico other = (Medico) obj;
		if (crm == null) {
			if (other.crm != null)
				return false;
		} else if (!crm.equals(other.crm))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return super.toString() +
				"CRM: " + getCrm() + "\n";
	}

	
}
